"""Sample some lines from a file"""
import argparse
import io
import numpy as np


def sample(in_fn, out_fn, n):
    lines = io.open(in_fn, encoding="utf-8").readlines()
    np.random.shuffle(lines)
    lines_sampled = lines[:n]
    out_f = io.open(out_fn, "w", encoding="utf-8")
    for line in lines_sampled:
        out_f.write(line.strip() + "\n")


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("in_fn")
    parser.add_argument("out_fn")
    parser.add_argument("num", type=int)
    args = parser.parse_args()

    in_fn = args.in_fn
    sample_num = args.num
    out_fn = args.out_fn

    sample(in_fn, out_fn, sample_num)

